package io.zhiller.ollamaclient.utils

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Process
import android.provider.Settings
import androidx.activity.ComponentActivity
import io.zhiller.ollamaclient.MainActivity

object IntentUtils {
  fun restartApp(context: Context) {
    val intent = Intent(context, MainActivity::class.java) // 替换为你的应用启动Activity
    intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
    context.startActivity(intent)
    Process.killProcess(Process.myPid())
  }
  
  fun closeApp(context: Context) {
    (context as ComponentActivity).finish()
  }
  
  fun openAppSettings(context: Context) {
    val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
      data = Uri.fromParts("package", context.packageName, null)
    }
    context.startActivity(intent)
  }
}